package server.model.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @description:
 * @author: 许哲
 * @createTime: 2021/11/21 17:36
 * @version: 1.0
 */
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@DynamicInsert
@DynamicUpdate
@ApiModel("充值流水")
public class MoneyRecord {
    @Id
    @GeneratedValue(generator = "NumberIdProduce")
    @GenericGenerator(name = "NumberIdProduce", strategy = "server.tool.idProduce.NumberIdProduce")
    private String id;

    private String systemCode;

    private BigDecimal money;

    @Column(unique = true)
    private String indentOrder;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @LastModifiedDate
    @Column
    private Date modifiedTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @CreatedDate
    @Column
    private Date createTime;

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum STATUS {
        ING("支付中", 0),
        ERROR("失败", -1),
        SUCCESS("成功", 1),
        TIMEOUT("超时", -2);

        STATUS(String display, int no) {
            this.display = display;
            this.no = no;
        }

        private String display;

        private int no;


        public int getNo() {
            return no;
        }

        public void setNo(int no) {
            this.no = no;
        }

        public String getDisplay() {
            return display;
        }

        public void setDisplay(String display) {
            this.display = display;
        }
    }

    @Enumerated(EnumType.STRING)
    @Column
    private STATUS status;

    private String dyAccount;

    private String dyOrder;

    private String url;

    private String cache;

    private String params;
}
